package io;


import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

public class ObjectOutputStreamDemo01 {
    public static void main(String[] args) throws IOException {
        Message m1 = new Message(1,"传奇病了","做了个小手术");
        Message m2 = new Message(1,"传奇快好了","估计下周上课");
        //1.构建流对象
        ObjectOutputStream oos =
                new ObjectOutputStream(
                        new FileOutputStream("message.txt"));
        //2.写对象（序列化）
        oos.writeObject(m1);
        oos.writeObject(m2);
        System.out.println("序列化OK");
        //3.关闭流对象
        oos.close();
    }
}
